import unittest
from unittest import TestLoader, TestSuite
from HtmlTestRunner import HTMLTestRunner
import os

# 创建报告目录
os.makedirs("reports", exist_ok=True)

print("0001")
# 加载测试用例
loader = TestLoader()
suite = TestSuite()
print("0002")
# 添加测试模块
suite.addTests(loader.loadTestsFromName("tests.test_login"))
# suite.addTests(loader.loadTestsFromName("tests.test_search"))
print('0003')
# 运行测试并生成HTML报告
with open("reports/test_report.html", "w") as f:
    runner = HTMLTestRunner(
        stream=f,
        report_title="Selenium Test Report",
        descriptions=True,
        verbosity=2
    )
    runner.run(suite)
print('0004')